use crate::api::*;
use crate::boot::err::*;

use actix_web::{http, HttpResponse, Result};
use serde_json::Value;
use std::collections::HashMap;

// 默认首页
// 启用 302 状态，执行页面跳转
pub async fn index() -> HttpResponse {
    let url = "/html/admin/login.html";
    HttpResponse::Ok()
        .append_header(("Location", url))
        .status(http::StatusCode::FOUND)
        .body("")
}

// 给前台页面返回配置参数
pub async fn sysconfig() -> Result<HttpResponse, MyError> {
    let mut hash_map = HashMap::<&str, Value>::new();
    hash_map.insert("appName", Value::String("测试用系统".into()));

    resp_ok(1, "登录成功", &hash_map)
}
